<?php
	include_once 'autoload.php';
	

	session_start();
	
	// we look for the request parameter called id, then for the file
	// if one of the two does not exist, we serve the filler
	header('Content-Type: application/image');

	$folder = PictureConfig::$CONTENT_FOLDER;
	
	$id = $_GET['id'];
	
	$file = "{$folder}pictures/small_{$id}.dat";

	$s = HtmlUtil::getSessionUser(); 
	
	// in case the user is not logged, will just provide the small filler.
	if($s->isLogged()){
		if(file_exists($file)){
			readfile($file);
		}
		else {
			readfile("{$folder}filler/small_filler.jpg");
		}
	}
	else {
		readfile("{$folder}filler/small_filler.jpg");
	}
?>